package com.ruima.study.arithmetic.sortdemo.practice;

/**
 * <p>
 * <p></p>
 * <p>
 * <p>Copyright (c) 2024/11/15 9:50, 科大讯飞 All Rights Reserve</p>
 *
 * @author ruima6
 * @version [V1.0]
 */
public class Demo1 {

    public static void main(String[] args) {
        int[] arrA = {1, 3, 5, 0, 0, 0};
        int[] arrB = {2, 4, 6,};
        merge(arrA, 3, arrB, 3);
        for (int i : arrA) {
            System.out.println(i);
        }
    }
    public static void merge(int[] arrA, int m, int[] arrB, int n) {
        Integer[] arr = new Integer[m + n];
        int i = 0;
        int j = 0;
        int count = 0;

        while (j < arrB.length) {
            if (arrA[i] < arrB[j] && arrA[i] != 0) {
                arr[count] = arrA[i];
                i++;
            } else {
                arr[count] = arrB[j];
                j++;
            }
            count++;
        }
        for (int k = 0; k < arr.length; k++) {
            arrA[k] = arr[k];
        }
    }
}
